
#include "stdafx.h"
#include "kernelMgr_t.h"



void kernelMgr_t::addKernel(kernelImpl_t* kernel)
{
	KER_MUTEX
	vector<kernelImpl_t*>::iterator iter;
	iter = find( kernels.begin(), kernels.end(), kernel );
	if (iter==kernels.end())
	{
		kernels.push_back(kernel);
	}
}


void kernelMgr_t::delKernel(kernelImpl_t* kernel)
{
	KER_MUTEX
	vector<kernelImpl_t*>::iterator iter;
	iter = find( kernels.begin(), kernels.end(), kernel );
	if (iter==kernels.end())
	{
		return;
	}
	kernels.erase(iter);
}


kernelImpl_t*		kernelMgr_t::getObjKernel( const UniqueID & obj )
{
	KER_MUTEX
	BaseObject* bo;
	vector<kernelImpl_t*>::iterator iter;
	for ( iter=kernels.begin(); iter!=kernels.end(); iter++ )
	{
		bo = (*iter)->getObj(obj);
		if (bo!=NULL)
		{
			return (*iter);
		}
	}

	return NULL;
}